import request from '@/utils/request'

export function codeCallback(redirectUri, code) {
  return request({
    url: `/api/codeCallback?code=${code}&redirectUri=${redirectUri}`,
    method: 'get'
  })
}

export function getInfo() {
  return request({
    url: '/api/getSsoUser',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/api/logout',
    method: 'get'
  })
}

export function userById(data) {
  return request({
    url: `/api/user/${data.userId}`,
    method: 'get'
  })
}

export function pageList(query) {
  return request({
    url: '/api/user/list/page',
    method: 'get',
    params: query
  })
}

export function createUser(data) {
  return request({
    url: '/api/user',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: '/api/user/' + data.id,
    method: 'put',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: '/api/user/' + data.id,
    method: 'Delete',
    data
  })
}  

export function syncUser() {
  return request({
    url: '/api/user/sync',
    method: 'get'
  })
}

export function updatePassword(data) {
  return request({
    url: '/api/user/updatePass',
    method: 'post',
    data
  })
}

export function updatePermission(data) {
  return request({
    url: `/api/user/permission/${data.userId}`,
    method: 'put',
    data
  })
}

export function findPermission() {
  return request({
    url: `/api/user/permission/me`,
    method: 'get'
  })
}
